Skip to content

Stop the whole fleet stampeding one advisory lock at boot - #142

Merged
maximusunc merged 1 commit into
mainfrom
claude/shepherd-startup-errors-xsnogv
Aug 28, 2026
Merged

Stop the whole fleet stampeding one advisory lock at boot#142
maximusunc merged 1 commit into
mainfrom
claude/shepherd-startup-errors-xsnogv

Conversation

@maximusunc

Copy link
Copy Markdown
Collaborator

All 23 DB-dependent containers start the instant Postgres reports healthy, and each one took a fleet-wide advisory lock to run the idempotent schema upgrades. On any volume created since those indexes landed in init_db.sql the upgrades are a no-op, but every container still queued for the lock, and whoever lost the queue blew postgres_pool_timeout and logged a PoolTimeout traceback on an otherwise healthy startup.

Add a pre-flight catalog check outside the lock, so the already-applied case costs one indexed read and no serialization, and retry the upgrade with the same backoff the query paths use instead of burning a single 5s attempt when the DB blips during those first seconds.

Also raise max_connections 200 -> 300. Both compose.yml and config.py document that the sum of per-container pool maxima must stay under it, but 22 workers at 10 plus the server at 30 is 250, so the invariant was already violated.

Claude-Session: https://claude.ai/code/session_01PQeAtdPFUgZ1BTB3UB6oXc

All 23 DB-dependent containers start the instant Postgres reports healthy, and
each one took a fleet-wide advisory lock to run the idempotent schema upgrades.
On any volume created since those indexes landed in init_db.sql the upgrades
are a no-op, but every container still queued for the lock, and whoever lost
the queue blew postgres_pool_timeout and logged a PoolTimeout traceback on an
otherwise healthy startup.

Add a pre-flight catalog check outside the lock, so the already-applied case
costs one indexed read and no serialization, and retry the upgrade with the
same backoff the query paths use instead of burning a single 5s attempt when
the DB blips during those first seconds.

Also raise max_connections 200 -> 300. Both compose.yml and config.py document
that the sum of per-container pool maxima must stay under it, but 22 workers at
10 plus the server at 30 is 250, so the invariant was already violated.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PQeAtdPFUgZ1BTB3UB6oXc
@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 54.06%. Comparing base (667465e) to head (6dd0ffa).
⚠️ Report is 18 commits behind head on main.

Files with missing lines Patch % Lines
shepherd_utils/db.py 93.33% 0 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ
shepherd_utils/config.py 95.32% <ø> (ø)
shepherd_utils/db.py 64.08% <93.33%> (+0.53%) ⬆️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5a30daf...6dd0ffa. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@maximusunc
maximusunc merged commit 9b27d60 into main Aug 28, 2026
2 checks passed
@maximusunc
maximusunc deleted the claude/shepherd-startup-errors-xsnogv branch August 28, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants